{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Updated Doing Nothing with Qiskit\n",
    "\n",
    "In this notebook, we demonstrate how to create and execute a quantum circuit using Qiskit. This updated code works with the latest version of Qiskit, addressing previous issues with deprecated functions and imports.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Importing Necessary Libraries\n",
    "\n",
    "First, we need to import the required libraries:\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "import qiskit\n",
    "import qiskit_aer"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Creating Quantum and Classical Registers\n",
    "\n",
    "We create a quantum register with 1 qubit and a classical register with 1 bit to store measurement results:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "qr = qiskit.QuantumRegister(1)\n",
    "cr = qiskit.ClassicalRegister(1)\n",
    "program = qiskit.QuantumCircuit(qr, cr)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Defining the Quantum Circuit\n",
    "\n",
    "Next, we define the quantum circuit and add a measurement operation:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<qiskit.circuit.instructionset.InstructionSet at 0x1f13fe2f100>"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "program.measure(qr, cr)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Selecting the Backend and Transpiling the Circuit\n",
    "We choose the qasm_simulator backend from Aer for simulation. The circuit is then transpiled to be compatible with this backend:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "backend = qiskit_aer.Aer.get_backend('qasm_simulator')\n",
    "program_ = qiskit.transpile(program, backend)\n",
    "job = backend.run(program_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Running the Circuit and Retrieving Results\n",
    "Finally, we run the transpiled circuit on the simulator and print the results:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'0': 1024}\n"
     ]
    }
   ],
   "source": [
    "result = job.result()\n",
    "counts = result.get_counts()\n",
    "print(counts)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Great! Now you are ready to create and execute programs!"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
